package com.example.prison.mapper;

import com.example.prison.entity.DepartmentInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author jiang
* @description 针对表【department_info】的数据库操作Mapper
* @createDate 2023-05-26 14:36:03
* @Entity com.example.prison.entity.DepartmentInfo
*/
@Mapper
public interface DepartmentInfoMapper extends BaseMapper<DepartmentInfo> {

    @Select("select * from department_info order by department_id desc")
    List<DepartmentInfo> get();

    @Insert("insert into department_info(department_name, remove, process) " +
            "values (#{departmentName}, #{remove}, #{process})")
    int add(DepartmentInfo department);

    @Delete("<script>delete from department_info where department_id in <foreach collection=\"ids\" item=\"item\" open=\"(\" separator=\",\" close=\")\">#{item} </foreach> </script>")
    void deleteDepartment(@Param("ids") Integer[] ids);

    @Delete("delete from department_info where department_id = #{id}")
    void deleteOneById(@Param("id") Integer ids);

    @Update("update department_info set department_name=#{department.departmentName}, remove=#{department.remove}, process=#{department.process} where department_id = #{id}")
    int updateDepartment(DepartmentInfo department,Integer id);

    @Update("update department_info set department_name=#{department.departmentName}, remove=#{department.remove}, process=#{department.process} where department_id = #{id}")
    int updateDepartmentFail(DepartmentInfo department,Integer id);

    @Select("select * from department_info where department_name like concat('%',#{name},'%') order by department_id desc")
    List<DepartmentInfo> getByName(@Param("name") String name);

    @Select("select * from department_info where department_name=#{name} order by department_id desc")
    List<DepartmentInfo> getBySameName(@Param("name") String name);

    @Select("select * from department_info where department_name=#{name}")
    DepartmentInfo getOneByName(@Param("name") String name);

    @Select("select * from department_info where department_id=#{id}")
    DepartmentInfo getById(@Param("id") Integer id);

}




